import { Component, OnInit } from '@angular/core';
import { User } from 'src/app/domain/user';
import {AdministrativeService} from '../../service/administrative.service'
import {OutRequest} from '../../domain/out-request'
/*

@Author:刘洋

@Date: 2018-12-12

@员工外出信息查询功能实现

@Last Modified time: 2018-12-16
*/
@Component({
  selector: 'app-administrative-out-info',
  templateUrl: './administrative-out-info.component.html',
  styleUrls: ['./administrative-out-info.component.css']
})
export class AdministrativeOutInfoComponent implements OnInit {

  constructor(private administrativeService:AdministrativeService) { }

  outRequest:OutRequest[];
  out:OutRequest;
  user:User = {
    id: undefined,
    user_name: '',
    name: '',
    age: undefined,
    sex: '',
    department: '',
    position: '',
    annual_leave_length: undefined,
    remain_annual_leave: undefined
  };
  ngOnInit() {
    this.getOutRequest();
  }
  getOutRequest(){
    this.administrativeService.getOutRequest()
    .subscribe(outRequest =>this.outRequest = outRequest);
  }
  getOutDetail(out:OutRequest){
    this.administrativeService.getUser(out.user_id)
    .subscribe(user =>this.user = user[0]);
    this.out = out;
  }
  getState(num:number){
    if(num == 0)
      return "拒绝外出";
    else if(num == 1)
      return "已通过";
    else if(num == 2)
      return "部门经理审批中";
    else if(num == 3)
      return "副总经理审批中";
    else if(num == 4)
      return "总经理审批中";
    else
      return "error"
  }
  getOutUser(id:number){
    this.administrativeService.getOutUser(id)
    .subscribe(outRequest =>this.outRequest = outRequest);
  }
}
